<link href="https://cdn.bootcss.com/weui/1.1.2/style/weui.min.css" rel="stylesheet">
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>

<style>
    .weui-cells{
        font-size: 13px;
    }
    body{
        padding-bottom: 40px;
    }
</style>
<div id='app' class='page'>
    <div class="weui-cells__title">订单详情</div>
    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">数量</label></div>
            <div class="weui-cell__bd">
                <input v-model='order.number' class="weui-input" type="number" placeholder="请输入数量">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">收货人ID</label></div>
            <div class="weui-cell__bd">
                <input v-model='order.shouhuo_uid' class="weui-input" type="number"  @change="change" placeholder="请输入收货人ID">
            </div>
        </div>
        
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">收货人姓名</label></div>
            <div class="weui-cell__bd">
                <input v-model='shouhuoren' class="weui-input"  placeholder="请输入收货人姓名" readonly>
            </div>
        </div>
        
    </div>
   
    <div class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <p>可拨货库存</p>
            </div>
            <div class="weui-cell__ft"><?=$memberinfo['stock']?></div>
        </div>
    </div>
    <div style='padding:20px 15px;'>
        <a @click='addOrder'  class="weui-btn weui-btn_primary">提交</a>
    </div>
</div>
<include file="Common:nav" />
<script src="https://cdn.bootcss.com/vue/2.4.4/vue.min.js"></script>
<script src="__STATIC__mobile/js/areadata.js"></script>
<script src="__STATIC__mobile/js/myarea.js"></script>
<script>


    var app = new Vue({
        el: '#app',
        data: {
            order: {
                number:'',
                shouhuo_uid:'',
            },
            smstext:'获取验证码',
            shouhuoren:''
        },
        mounted: function () {
            city.getcity('province','city','county','<?php echo $delivery["province"];?>','<?php echo $delivery["city"];?>','<?php echo $delivery["county"];?>',1);
        },
        methods: {
            addOrder: function () {
                var self = this;
                var cfm = weui.confirm('确定提交订单吗?',function(){
                    var loading = weui.loading('loading');
                    $.ajax({
                        url:'/mobile/orderadd/transfer',
                        data: self.order,
                        type:'post'
                    }).then(function(res){
                        loading.hide();
                        if(res.ret==1) {
                            showerror(res.msg);
                        }else if(res.ret==0){
                            showsuccess(res.msg,res.url);
                        }
                    });
                })
            },
            getsmscode: function () {
                AjaxUrl('/mobile/user/getsmscode');
                this.smstext = '已发送';
            },
            change: function() {
            	
				var self = this;
                var uid = self.order.shouhuo_uid;
                this.shouhuoren = '';
                
                layer.open({type: 2});
                $.get('/mobile/cart/getuserinfo2?uid='+uid,function(res){
                    layer.closeAll();
                    if(res.ret==1) {
                        showerror(res.msg);
                        self.shouhuoren = '';
                    }else {
                    	self.shouhuoren = res.data.realname;
                    	
                    }
                    
                })
            }
        }
    });
</script>